package main

import (
	"net/http"

	"github.com/gin-gonic/gin"

	"traning/gin_training/ch07/proto"
)

func main() {
	router := gin.Default()

	router.GET("/", moreJson)
	router.GET("/proto", moreproto)

	router.Run(":8080")
}

func moreproto(c *gin.Context) {
	course := []string{"go", "算法"}
	user := &proto.Tearcher{
		Name: "ice",
		Course: course,
	}
 	c.ProtoBuf(http.StatusOK, user)
}

func moreJson(c *gin.Context) {
	var user struct {
		Name string `json:"name"`
		Age  int
	}
	user.Name = "ice"
	user.Age = 18
	c.JSON(http.StatusOK, user)
}
